package com.servlet;

import java.awt.Frame;
import java.io.IOException;
import java.util.Date;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import com.xiaonei.DAO.*;

/**
 * Servlet implementation class PostServlet
 */
//@WebServlet("/PostServlet")
public class AddSchool extends HttpServlet {
private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddSchool() {
        super();
        // TODO Auto-generated constructor stub
    }

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");

String name = request.getParameter("name");
String type = request.getParameter("type");
String introduction = request.getParameter("introduction");
String province = request.getParameter("province");
String city = request.getParameter("city");
String address = request.getParameter("address");
System.out.println("AddTopicServlet里面"+name);
System.out.println("AddTopicServlet里面"+type);

//鐢╰opicContent寰楀埌topicNum锟�
SchoolsDAOImpl schoolsDAOImpl=new SchoolsDAOImpl();
if(schoolsDAOImpl.AddSchool(name,type,introduction,province,city,address)) {
	JOptionPane.showMessageDialog(new Frame(),"添加学校成功");
	request.getRequestDispatcher("/guanliyuan/AddTopic.jsp").forward(request, response);
}else{
	JOptionPane.showMessageDialog(new Frame(),"添加学校失败");
	request.getRequestDispatcher("/guanliyuan/AddTopic.jsp").forward(request, response);}
}

}